import React, { useEffect, useState } from 'react'
import { useNavigate } from 'react-router-dom'

const useLogin = () => {
    const nav=useNavigate()
    const token=localStorage.getItem('token')
    const [islogin,setIslogin]=useState(false)
    useEffect(()=>{
        if(token){
            setIslogin(true)
        }else if(!token)
        {
            setIslogin(false)
            nav('/login')
        }
    },[])
  return {islogin:islogin}
}

export default useLogin
